The present invention relates to electronic image processing.
An electronic image, such as a digital image, can be represented by an array of closely packed pixels that are basic picture elements. Each pixel represents a local portion of the image, and alone or together with other pixels determines local attributes such as color, gray level, luminosity, transparency or other graphical attributes of the local image portion.
Electronic images are generated or processed by graphical software applications, such as presentation, animation, painting and design applications, or by electronic devices, such as scanners and digital cameras. During image processing, different electronic filters can be used to adjust the image. In general, a filter applies a transformation to pixels of an input image to generate an output image. Electronic filters can achieve various visual effects. Some electronic filters mimic conventional photographic filters such as lenses and apertures that blur, sharpen or otherwise transform images. Other filters transform images in unusual ways. For example, a pointillism filter transforms a digitized photograph into a pointillistic painting in which small strokes of color are applied, so that from a distance the strokes blend together to represent objects in the painting.
One traditional filtering effect is depth of field filtering that changes the depth in which objects seem to be in focus. When imaged by a conventional or digital camera, objects are in focus at a focal distance from the camera. The optics of the camera maps objects at the focal distance to a focal plane defined by the film of the conventional camera or the sensor array of the digital camera. Objects that are closer or farther away than the focal distance are mapped in front of or behind the focal plane and may appear blurred in the photograph. A large depth of field allows objects to seem to be in focus even at distances from the film or sensor that are much larger or smaller than the focal distance. A small depth of field means that only objects at or near the focal distance seem to be in focus and other objects seem blurred.
For electronic depth of field filtering of an image, the local attributes of each pixel include a depth value corresponding to a difference between the focal distance and the distance of the object represented by the pixel from the focal plane. To narrow a large depth of field electronically, a blur filter is selectively applied to different pixels of the digital image based upon the depth values of the pixels. No blur is applied to pixels that have zero depth values corresponding to objects at the focal distance, and a blur is applied at pixels that have non-zero depth values corresponding to objects that are closer or farther than the focal distance. The larger the difference between the focal distance and an object's distance from the focal plane, the more blur is applied to the pixels representing that object. Before applying a depth of field filter, the depth values of the pixels can be arbitrarily defined or altered by a user or a computer application.
A filter typically uses a kernel to generate a filtered value for a pixel whose location is referred to as the center of the kernel. The kernel defines weights that are assigned to pixels in a neighborhood surrounding the kernel's center in the image. The set of pixels that have substantially non-zero weights is referred to as the kernel's support. For example, an optical blur filter typically uses a flat kernel that assigns substantially uniform non-zero weights to all pixels within its support, such as a circular or rectangular support surrounding the kernel's center. When the filter is applied to a pixel, a filtered value is generated such that each neighborhood pixel within the kernel's support contributes to the filtered value in proportion to the weight assigned to the neighborhood pixel.